package com.fr.similarity;

import java.util.ArrayList;
import java.util.List;


/**
 * 年薪范围筛选器
 * @author Smile.Wu
 *
 */
public class AnnualSalaryCaculator  {

	private List<AnnualSalaryRange> prices = new ArrayList<AnnualSalaryRange>();
	
	private static List<AnnualSalaryRange> items = new ArrayList<AnnualSalaryRange>();
	static {
		items.add(new AnnualSalaryRange(0, 10, "0-10"));
		items.add(new AnnualSalaryRange(10, 20, "10-20"));
		items.add(new AnnualSalaryRange(20, 30, "20-30"));
		items.add(new AnnualSalaryRange(30, 50, "30-50"));
		items.add(new AnnualSalaryRange(50, Integer.MAX_VALUE, "50-" + Integer.MAX_VALUE));
	}
	
	private int rangeNum = 7;
	
	public AnnualSalaryCaculator() {
		
	}
	public AnnualSalaryCaculator(int rangeNum) {
		this.rangeNum = rangeNum;
	}

	public void addPriceRange(AnnualSalaryRange pr) {
		if(pr.isValidate()) {
			this.prices.add(pr);
		}
	}
	public int getRangeNum() {
		return rangeNum;
	}
	public void setRangeNum(int rangeNum) {
		this.rangeNum = rangeNum;
	}
	
	

	public static String compartPrice(double price) {
		if(price < 10) {
			return "0-10";
		} else if(price < 20) {
			return "10-20";
		} else if(price < 30) {
			return "20-30";
		} else if(price < 50) {
			return "30-50";
		} else {
			return "50-" + Integer.MAX_VALUE;
		}
	}

	/**
	 * 实际薪水范围，计算区间段
	 * @param min
	 * @param max
	 * @return
	 */
	public static List<String> compartPrice(double min, double max) {
		List<String> rs = new ArrayList<String>();
		
		for(AnnualSalaryRange range : items) {
			if(min < range.getRight() && max >= range.getLeft()) {
				rs.add(range.getAppendString());
			}
		}
		
		return rs;
	}
	public static void main(String[] args) {
		System.out.println(compartPrice(0, 0));
		System.out.println(Integer.MAX_VALUE);
	}
}
